package com.boco.pciv.entity.sys;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * 用户信息表
 * 
 * @author pciv
 * @email pciv@boco.com.cn
 * @date 2018-07-10 15:10:20
 */
public class UserInfo implements Serializable {
	private static final long serialVersionUID = 1L;
	
	//id
	private Integer id;

	private String userId;

	private String password;
	//姓名

	private String userName;
	//性别

	private String sex;
	//邮箱地址
	private String mail;
	//电话
	private String phone;
	//状态：1:激活，2:锁定，3:删除
	private Integer state;
	private String stateName;
	//部门
	private String deptId;
	private String deptName;
	//地市
	private String cityId;
	private String cityName;
	//上次登录时间
	private Date lastLoginTime;
	private String lastLoginTimeStr;
	//描述
	private String remarks;
	//创建人
	private String createUser;
	//创建时间
	private Date createTime;
	//修改人
	private String updateUser;
	//修改时间
	private Date updateTime;
    @JsonIgnore
	private String salt;
	private List<RoleBasicInfo> roles;
    private String[] roleIds;
    private String roleNames;
	private String code;
	//账号类型  0基本账号  1 劳务公司账号 2 建筑公司账号
	private Integer userType;

	public Integer getUserType() {
		return userType;
	}

	public void setUserType(Integer userType) {
		this.userType = userType;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getId() {
		return id;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUserId() {
		return userId;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getPassword() {
		return password;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getUserName() {
		return userName;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getSex() {
		return sex;
	}
	public void setMail(String mail) {
		this.mail = mail;
	}
	public String getMail() {
		return mail;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getPhone() {
		return phone;
	}
	public void setState(Integer state) {
		this.state = state;
	}
	public Integer getState() {
		return state;
	}
	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}
	public String getDeptId() {
		return deptId;
	}
	public void setCityId(String cityId) {
		this.cityId = cityId;
	}
	public String getCityId() {
		return cityId;
	}
	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}
	public Date getLastLoginTime() {
		return lastLoginTime;
	}
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	public String getRemarks() {
		return remarks;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setSalt(String salt) {
		this.salt = salt;
	}
	public String getSalt() {
		return salt;
	}

    public List<RoleBasicInfo> getRoles() {
        return roles;
    }

    public void setRoles(List<RoleBasicInfo> roles) {
        this.roles = roles;
    }
    public String[] getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(String[] roleIds) {
        this.roleIds = roleIds;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getRoleNames() {
        if (StrUtil.isBlank(roleNames)){
            roleNames="";
            for (RoleBasicInfo role : roles) {
                if (StrUtil.isBlank(role.getRoleName())) continue;
                roleNames += role.getRoleName()+";";
            }
        }
        return roleNames;
    }

    public void setRoleNames(String roleNames) {
        this.roleNames = roleNames;
    }

    public String getStateName() {
	    //1:激活，2:锁定，3:删除
        if (state==3){
            stateName= "删除";
        }
        else if (state==2){
            stateName= "锁定";
        }
        else{
            stateName ="激活";
        }
	    return stateName;
    }

    public String getLastLoginTimeStr() {
	    if (lastLoginTime!=null){
            lastLoginTimeStr = DateUtil.formatDateTime(lastLoginTime);
        }
        return lastLoginTimeStr;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
